﻿using GroupThreeMESProject.DTO;
using GroupThreeMESProject.Entity;
using GroupThreeMESProject.Result;
using GroupThreeMESProject.ShrDTo;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using static System.Reflection.Metadata.BlobBuilder;

namespace GroupThreeMESProject.Service
{
    [ApiExplorerSettings(GroupName = "v2")]
                                    
    public class MesMaterialService:ApplicationService
    {
        private readonly ISqlSugarClient _db;

        public MesMaterialService(ISqlSugarClient db)
        {
            _db = db;
        }
        [HttpGet("Login/MesMaterialShow")]
        public async Task<ApiResult<List<MesMaterialDto>>> MesMaterialShow()
        {
            var query5 = await  _db.Queryable<MesMaterial>().ToListAsync();
            int n = 0;
            var list = await _db.Queryable<MesMaterial, MesMaterialType>((a, b) => a.MaterialId == b.MaterialTypeId).Select((a, b) => new MesMaterialDto
            {
                MaterialId=a.MaterialId,
                MaterialTypeId = b.MaterialTypeId,
                MaterialName=b.MaterialTypeName,
                MaterialNumbering=a.MaterialNumbering
            }).ToListAsync();

            return ApiResult<List<MesMaterialDto>>.Success(list);
        }
    }
}